# 360搜索操作
from selenium import webdriver
import time

"""
driver = webdriver.Chrome()
time.sleep(2)
driver.get('https://www.so.com')
time.sleep(2)

driver.find_element_by_id('input').send_keys('天气预报')
time.sleep(2)

driver.find_element_by_id('search-button').click()
time.sleep(2)

driver.quit()

# selenium 完成两遍
driver = webdriver.Firefox()
driver.get('https://www.baidu.com')
time.sleep(2)

driver.find_element_by_id('kw').send_keys('广元地图')
time.sleep(2)

driver.find_element_by_id('su').click()
time.sleep(2)

driver.quit()

if '广元' in driver.title:
    print('广元有这几个字')
else:
    print('啥也没有')


# 第二遍

class MapCase:
    def __init__(self):
        self.driver = webdriver.Chrome()

    def get_baidu(self):
        self.driver.get('https://www.baidu.com')

        self.driver.find_element_by_id('kw').send_keys('广元地图')
        self.driver.find_element_by_id('su').click()

        time.sleep(1)
        print(self.driver.title)
    def get_so(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://www.so.com')
        self.driver.find_element_by_id('input').send_keys('广元地图')
        self.driver.find_element_by_id('search-button').click()
        time.sleep(1)
        print(self.driver.title)

    def quit(self):
        time.sleep(1)
        self.driver.quit()

if __name__ == '__main__':
    map = MapCase()
    map.get_baidu()
    map.get_so()
    map.quit()
    
"""

# 打开百度浏览器相关操作

driver = webdriver.Firefox()
driver.get('https://www.baidu.com')
time.sleep(1)

driver.set_window_size(400,800)  # 窗口400宽 800长
time.sleep(1)

driver.maximize_window()  # 最大化窗口
time.sleep(1)

driver.find_element_by_id('kw').send_keys('广元地图')
driver.find_element_by_id('su').click()
time.sleep(3)
driver.back()  # 后退
time.sleep(3)

driver.forward()  # 前进
time.sleep(3)

driver.refresh()
time.sleep(3)

driver.back()  # 后退
time.sleep(3)


driver.find_element_by_link_text('新闻').click()
time.sleep(3)
driver.close()

# driver.minimize_window()  # 最小化窗口
time.sleep(1)
driver.quit()